<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改考核人员')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body>
<div class="main-content">
    <form id="form-grade-edit" class="form-horizontal" th:object="${grade}">
        <input name="gradeId" id="gradeId" type="hidden"  th:field="*{gradeId}" />
        <input name="examTime" id="examTime" type="hidden"  th:field="*{examTime}" />
        <input name="personnelCategory" id="personnelCategory" type="hidden"  th:field="*{personnelCategory}" />
        <h4 class="form-header h4">考核成绩</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">姓名：</label>
                    <div class="col-sm-8">
                        <input name="examPersonnel" id="examPersonnel" placeholder="请输入考核人姓名" class="form-control" th:field="*{examPersonnel}"
                               type="text" maxlength="30" required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">年龄：</label>
                        <div class="col-sm-8">
                            <input name="age" id="age" placeholder="请输入考核人年龄" class="form-control" th:field="*{age}" type="text" maxlength="30" required>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">性别：</label>
                    <div class="col-sm-8">
                        <select name="gender" id="gender" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{gender}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">体型：</label>
                        <div class="col-sm-8">
                            <input name="bodilyForm" id="bodilyForm" placeholder="请输入考核人身高" class="form-control" th:field="*{bodilyForm}" type="text" maxlength="30" required>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">3000米跑：</label>
                        <div class="col-sm-8">
                            <input name="threeKmScore" id="threeKmScore" placeholder="请输入3000米跑成绩" class="form-control" th:field="*{threeKmScore}" type="text" maxlength="30" required>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">单杠/俯卧撑：</label>
                        <div class="col-sm-8">
                            <input name="horizontalbarPushupScore" id="horizontalbarPushupScore" placeholder="请输入单杠/俯卧撑成绩" class="form-control" th:field="*{horizontalbarPushupScore}" type="text" maxlength="30" required>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">仰卧起坐：</label>
                        <div class="col-sm-8">
                            <input name="situpScore" id="situpScore" placeholder="请输入仰卧起坐成绩" class="form-control" th:field="*{situpScore}" type="text" maxlength="30" required>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">30米×2蛇形跑：</label>
                        <div class="col-sm-8">
                            <input name="snakeRunScore" id="snakeRunScore" placeholder="请输入30米×2蛇形跑成绩" class="form-control" th:field="*{snakeRunScore}" type="text" maxlength="30" required>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">总分：</label>
                        <div class="col-sm-8">
                            <input name="totalScore" id="totalScore" placeholder="请输入总分" class="form-control" th:field="*{totalScore}" type="text" maxlength="30" required>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">成绩评定：</label>
                        <div class="col-sm-8">
                            <input name="gradeEvaluation" id="gradeEvaluation" placeholder="请输入蛇形跑成绩" class="form-control" th:field="*{gradeEvaluation}" type="text" maxlength="30" required>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<div class="row">
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script type="text/javascript">
    var prefix = ctx + "examine/grade";
    var prefix_validate = ctx + "examine/personnel";

    $("#form-grade-edit").validate({
        onkeyup: false,
        rules:{
            examPersonnel:{
                minlength: 2,
                maxlength: 20,
                remote: {
                    url: prefix_validate + "/checkPersonnelNameUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "examPersonnel": function() {
                            return $.common.trim($("#examPersonnel").val());
                        }
                    },
                    dataFilter: function(data, type) {
                        return $.validate.unique(data);
                    }
                }
            }
        },
        messages: {
            "examPersonnel": {
                remote: "考核人员已经存在"
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        var gradeId = $("#gradeId").val();
        var personnelCategory = $("#personnelCategory").val();
        var examPersonnel = $("#examPersonnel").val();
        var age = $("#age").val();
        var gender = $("#gender").val() === "0" ? "男" : "女";
        var bodilyForm = $("#bodilyForm").val();
        var threeKmScore = $("#threeKmScore").val();
        var horizontalbarPushupScore = $("#horizontalbarPushupScore").val();
        var situpScore = $("#situpScore").val();
        var snakeRunScore = $("#snakeRunScore").val();
        var totalScore = $("#totalScore").val();
        var gradeEvaluation = $("#gradeEvaluation").val();
        var examTime = $("#examTime").val();

        var data = [];

        data.push({"name": "gradeId", "value": gradeId});
        data.push({"name": "personnelCategory", "value": personnelCategory});
        data.push({"name": "examPersonnel", "value": examPersonnel});
        data.push({"name": "age", "value": age});
        data.push({"name": "gender", "value": gender});
        data.push({"name": "bodilyForm", "value": bodilyForm});
        data.push({"name": "threeKmScore", "value": threeKmScore});
        data.push({"name": "horizontalbarPushupScore", "value": horizontalbarPushupScore});
        data.push({"name": "situpScore", "value": situpScore});
        data.push({"name": "snakeRunScore", "value": snakeRunScore});
        data.push({"name": "totalScore", "value": totalScore});
        data.push({"name": "gradeEvaluation", "value": gradeEvaluation});
        data.push({"name": "examTime", "value": examTime});
        $.operate.saveTab(prefix + "/edit", data);
    }


    function doSubmit(index, layero){
        var tree = layero.find("iframe")[0].contentWindow.$._tree;
        var body = layer.getChildFrame('body', index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        layer.close(index);
    }

    $(function() {
        // 6	黄平	1987年5月1日	33	男						俯卧撑				2021年3月	三类人员
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '#birthday'
            });
        });
    })
</script>
</body>
</html>
